home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Beziers and Other Splines / BezierClock / BezierClockControl.cs < prev   
Encoding:
Text File  |  2001-01-15  |  2.0 KB  |  53 lines

  1. //-------------------------------------------------
  2. // BezierClockControl.cs ⌐ 2001 by Charles Petzold
  3. //-------------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Windows.Forms;
  8.  
  9. namespace Petzold.ProgrammingWindowsWithCSharp
  10. {
  11. class BezierClockControl: ClockControl
  12. {
  13.      protected override void DrawHourHand(Graphics grfx, Pen pen)
  14.      {
  15.           GraphicsState gs = grfx.Save();
  16.           grfx.RotateTransform(360f * Time.Hour / 12 +
  17.                                 30f * Time.Minute / 60);
  18.  
  19.           grfx.DrawBeziers(pen, new Point[]
  20.           {
  21.                new Point(  0, -600), new Point(   0, -300), 
  22.                new Point(200, -300), new Point(  50, -200), 
  23.                new Point( 50, -200), new Point(  50,    0),
  24.                new Point( 50,    0), new Point(  50,   75), 
  25.                new Point(-50,   75), new Point( -50,    0), 
  26.                new Point(-50,    0), new Point( -50, -200),
  27.                new Point(-50, -200), new Point(-200, -300), 
  28.                new Point(  0, -300), new Point(   0, -600)
  29.           });
  30.           grfx.Restore(gs);
  31.      }
  32.      protected override void DrawMinuteHand(Graphics grfx, Pen pen)
  33.      {
  34.           GraphicsState gs = grfx.Save();
  35.           grfx.RotateTransform(360f * Time.Minute / 60 +
  36.                                  6f * Time.Second / 60);
  37.  
  38.           grfx.DrawBeziers(pen, new Point[]
  39.           {
  40.                new Point(  0, -800), new Point(   0, -750), 
  41.                new Point(  0, -700), new Point(  25, -600), 
  42.                new Point( 25, -600), new Point(  25,    0),
  43.                new Point( 25,    0), new Point(  25,   50), 
  44.                new Point(-25,   50), new Point( -25,    0), 
  45.                new Point(-25,    0), new Point( -25, -600),
  46.                new Point(-25, -600), new Point(   0, -700), 
  47.                new Point(  0, -750), new Point(   0, -800)
  48.           });
  49.           grfx.Restore(gs);
  50.      }
  51. }
  52. }
  53.